﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;

namespace FY13.Converter
{
    public class UserInfoConverter : IValueConverter
    {
        private static readonly string[] Months = new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" };
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                Data.UserInfo user = value as Data.UserInfo;
                string str = null;
                switch (int.Parse(parameter.ToString()))
                {
                    case 1:
                        str = user.DepartureTrip;
                        str.Split(new string[] { "->" }, StringSplitOptions.None);
                        str = str.Split(new string[] { "->" }, StringSplitOptions.None)[0];
                        return str;
                    case 2:
                        str = user.DepartureTrip;
                        str = str.Split(new string[] { "->" }, StringSplitOptions.None)[1];
                        return str;
                    case 3:
                        return DateTime.Parse(user.DepartureDate);
                    case 4:
                        return user.DepartureFlight.Split(' ')[0];
                    case 5:
                        return user.DepartureFlight.Split(' ')[1];

                    case 6:
                        str = user.ReturnTrip;
                        str.Split(new string[] { "->" }, StringSplitOptions.None);
                        str = str.Split(new string[] { "->" }, StringSplitOptions.None)[0];
                        return str;
                    case 7:
                        str = user.ReturnTrip;
                        str = str.Split(new string[] { "->" }, StringSplitOptions.None)[1];
                        return str;
                    case 8:
                        return DateTime.Parse(user.ReturnDate);
                    case 9:
                        return user.ReturnFlight.Split(' ')[0];
                    case 10:
                        return user.ReturnFlight.Split(' ')[1];
                    case 11:
                        //var date = DateTime.Parse(user.HotelCheckOutTime);
                        var date = new DateTime(2012, 11, 1, 9, 0, 0);
                        return string.Format("{0} {1}", Months[date.Month], date.Day);
                    case 12:
                        //var date = DateTime.Parse(user.HotelCheckOutTime);
                        var d = new DateTime(2012, 11, 1, 9, 0, 0);
                        if (d.Hour < 12)
                            return d.ToShortTimeString() + " AM";
                        else
                            return d.ToShortTimeString() + " PM";
                    case 13:

                        break;
                    default:
                        break;
                }
                return str;
            }
            catch
            {
                return null;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
